<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@page import="com.pojo.User"%>
<%@page import="com.Dao.UserDao"%>
<%	
	//获取到项目的绝对路径
	String basePath = request.getScheme()
			+"://"+request.getServerName()
			+":"+request.getServerPort()
			+request.getContextPath()+"/";
	request.setCharacterEncoding("UTF-8");
	String adderss =(String)session.getAttribute("address");
	String userName = request.getParameter("userName");
	String userPhone = request.getParameter("userPhone");
	String userEmail = request.getParameter("userEmail");
	String userPsw = request.getParameter("userPsw");
	String reuserPsw = request.getParameter("reuserPsw");
	//判断是否已经存在此分类
	User user = new User(0,userName,userPhone,userEmail,userPsw,reuserPsw);
	//判断账户是否在数据库中
	UserDao userDao = new UserDao();
	User result = userDao.findUserByUser(user);
	Integer countx = (Integer)session.getAttribute("countx");
	
	if(null == countx){
		countx = 0;
	}
	
	if(result != null){
		//把用户保存到session
		session.setAttribute("user",result);
		countx=1;
		session.setAttribute("countx",countx);
		
		response.sendRedirect(basePath+adderss);
	}
	else{//失败，返回到登录页面(通过绝对路径访问)
		countx=2;
		session.setAttribute("countx",countx);
		response.sendRedirect(basePath+"login/login.jsp");
	}
	
	
%>